package com.audaque.springboot.foshanupload.web.datamongodbmodeldemo.model.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.mongodb.morphia.annotations.Entity;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * @author zgb
 * @desc ...
 * @date 2023-07-23 02:17:24
 */

@Entity
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Document(collection = "music_detail")
public class MusicDetail implements Serializable {
    /**
     * MongoClient
     * id与_id独立
     * id
     * 任意类型
     * 插入时手动添加
     * <p>
     * _id
     * ObjectId
     * 插入时自动添加
     * <p>
     * spring data
     *
     * @Id标注id，是id=_id
     */
    //使用 @Id 注解的字段作为文档的 _id 值
    @Id
    @Field(value = "_id")
    //与实际对应
    private String _id;//主键

    private String id;//音乐ID

    @Getter
    @Setter
    private String musicName;//音乐名称

    @Getter
    @Setter
    private String musicType;//音乐类型

    @Getter
    @Setter
    private String author;//音乐表演者

    @Getter
    @Setter
    private String album;//所属专辑

    @Getter
    @Setter
    //添加两个注解
    //用于post的boday的json
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    //用于get的params
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date addTime;//添加时间

    //不要使用懒加载
    @DBRef(lazy = false)
    private Book book;


}
